<script setup lang="ts">
import { useAccountStore } from "@/stores/account";
import { handleToPage } from "@/utils";

const { logout } = useAccountStore();

function handleLogout(){
  logout();
  uni.switchTab({ url: "/pages/tabbar/home" });
}
</script>

<template>
<view class="relative overflow-hidden">
  <view class="sticky top-0">
    <uv-navbar bgColor="transparent" title="" placeholder autoBack></uv-navbar>
  </view>

  <page-title title="设置"></page-title>

  <view class="mx-4 rounded-lg bg-white grid gap-3 p-3 mt-5">
    <view class="flex items-center justify-between" @click="handleToPage(`/pages/account/agreement?type=user`)">
      <view class="text-(sm #333333)">用户服务协议</view>
      <view class="i-ri-arrow-right-s-line text-#999999"></view>
    </view>
    <view class="flex items-center justify-between" @click="handleToPage(`/pages/account/agreement?type=privacy`)">
      <view class="text-(sm #333333)">隐私政策</view>
      <view class="i-ri-arrow-right-s-line text-#999999"></view>
    </view>
  </view>
 
  <view class="mx-4 rounded-lg bg-white grid gap-3 px-3 mt-5" @click="handleToPage('/pages/user/feedback')">
    <view class="flex items-center justify-between py-3">
      <view class="text-(sm #333333)">意见反馈</view>
      <view class="i-ri-arrow-right-s-line text-#999999"></view>
    </view>
  </view>

  <view class="w-86 fixed bottom-5 mb-[--safe-area-inset-bottom] left-50% -translate-x-50% z-10">
    <uv-button
      size="large"
      text="退出登录"
      :custom-style="{
        fontSize: '18px',
        height: '48px',
        borderRadius: '8px',
        borderColor: 'transparent'
      }"
      @click="handleLogout()"
    ></uv-button>
  </view>
</view>  
</template>
